# Maintainer: Andrea Zagli <andrea.zagli.free@gmail.com>

_realname=geocode-glib
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=3.26.2
pkgrel=1
arch=('any')
pkgdesc="Helper library for geocoding services (mingw-w64)"
license=("LGPL")
url="https://gitlab.gnome.org/GNOME/geocode-glib"
install=${_realname}-${CARCH}.install
depends=("${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-json-glib"
         "${MINGW_PACKAGE_PREFIX}-libsoup")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
            "${MINGW_PACKAGE_PREFIX}-pkg-config"
            "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
            "${MINGW_PACKAGE_PREFIX}-gtk-doc"
            "${MINGW_PACKAGE_PREFIX}-meson"
            "${MINGW_PACKAGE_PREFIX}-ninja")
options=('strip' '!debug' 'staticlibs')
source=(https://download.gnome.org/sources/${_realname}/${pkgver:0:4}/${_realname}-${pkgver}.tar.xz
        001-locale.patch)
sha256sums=('01fe84cfa0be50c6e401147a2bc5e2f1574326e2293b55c69879be3e82030fd1'
            '7379362319bab800b464ae4cf1d33e05f51bf500d8b0f65be63c05036f040c34')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -Np1 -i ${srcdir}/001-locale.patch

  # From Arch
  sed -i 's/gnome/Adwaita/' icons/meson.build
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}" && cd "${srcdir}/build-${MINGW_CHOST}"

  meson \
    --buildtype=plain \
    -Denable-introspection=true \
    -Denable-gtk-doc=true \
    "../${_realname}-${pkgver}"
  ninja
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  DESTDIR="${pkgdir}${MINGW_PREFIX}" ninja install

  sed -s "s|$(cygpath -m ${MINGW_PREFIX})|${MINGW_PREFIX}|g" -i "${pkgdir}${MINGW_PREFIX}/lib/pkgconfig/${_realname}-1.0.pc"

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING.LIB" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING.LIB"
}
